﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MediaDataModel;

namespace MediaClient.Shelf
{
    public partial class DiscCheckInForm : BaseSmallForm
    {
        public string DiscBarcode = null;

        public DiscCheckInForm()
        {
            InitializeComponent();
        }

        private void lblSubmit_Click(object sender, EventArgs e)
        {
            this.DiscBarcode = txtBarcode.Text.Trim();
            if (DiscBarcode != "")
            {
                using (CCTV6Entities db = new CCTV6Entities())
                {
                    BlueDisc oDisc = db.BlueDiscs.SingleOrDefault(disc => disc.Barcode == DiscBarcode);
                    if (oDisc == null)
                    {
                        this.DiscBarcode = "";
                        txtBarcode.Focus();
                        MessageBox.Show("条形码有误，请重新扫描或者重新手工输入。", BaseForm.MessageBoxCaption);
                        return;
                    }
                }
            }
            this.Close();
        }

        private void lblSubmit_MouseMove(object sender, MouseEventArgs e)
        {
            lblSubmit.Image = global::MediaClient.Properties.Resources.下一步_1;
        }

        private void lblSubmit_MouseLeave(object sender, EventArgs e)
        {
            lblSubmit.Image = global::MediaClient.Properties.Resources.下一步;
        }

        private void lblClose_Click(object sender, EventArgs e)
        {
            this.DiscBarcode = "";
        }
    }
}
